package com.project2.controller;


import com.project2.bean.ResultVo;
import com.project2.bean.po.MarketFeedback;
import com.project2.service.WxFeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

/**
 * @Author: MH
 * @Date: 2022-08-15 17:30
 * @Description: 前台意见反馈,其中要对手机号码的长度进行校验
 */
@RestController
@RequestMapping("wx/feedback")
public class WxFeedbackController {
    @Autowired
    WxFeedbackService wxFeedbackService;

    @RequestMapping("submit")
    public ResultVo submit(@RequestBody @Valid MarketFeedback marketFeedback, BindingResult bindingResult, HttpServletRequest request) {
        // 如果手机号码长度不是11位,就直接提示参数不对
        if (bindingResult.hasFieldErrors()) {
            return ResultVo.wrong("参数不对");
        }
        wxFeedbackService.submitInfo(marketFeedback,request);
        return ResultVo.ok();
    }
}
